//
//  RootChannelViewController.m
//  FNer
//
//  Created by dllo on 15/11/4.
//  Copyright © 2015年 刘志强. All rights reserved.
//

#import "RootChannelViewController.h"
#import "ChannelMineViewController.h"
#import "ChannelViewController.h"
@interface RootChannelViewController ()


@property (nonatomic, strong)ChannelMineViewController *chanMine;
@property (nonatomic, strong)ChannelViewController *channel;

@end

@implementation RootChannelViewController
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.chanMine.myTableView reloadData];
    
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    
    UISegmentedControl *sage = [[UISegmentedControl alloc]initWithItems:[NSArray arrayWithObjects:@"全部频道",@"我的频道", nil]];
    sage.selectedSegmentIndex = 0;
    
    [sage initWithRect:57.5 andY:0 andWidth:160 andheight:30];
    [sage addTarget:self action:@selector(sageAvtion:)   forControlEvents:(UIControlEventValueChanged)];
    self.navigationItem.titleView = sage;
    
    
    
    //将Root 作为两个页面的试图控制器
    
    self.chanMine = [[ChannelMineViewController alloc]init];
    self.channel = [[ChannelViewController alloc]init];
    
    [self addChildViewController:self.channel];
    [self addChildViewController:self.chanMine];
    
    [self.view addSubview:self.chanMine.view];
    [self.view addSubview:self.channel.view];
    
}




- (void)sageAvtion:(UISegmentedControl *)sage
{
    if (sage.selectedSegmentIndex == 0) {
        [self.view bringSubviewToFront:self.channel.view];
    }
    else
    {
        [self.view bringSubviewToFront:self.chanMine.view];
    }
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
